﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using Project.MVC.DataAccess;
@using Project.MVC.Admin.Models;
@model ProductModel
@*@using (Html.BeginForm("Add", "News", new { type = Model.Type }, FormMethod.Post, new { id = "newHotnessForm" }))*@
@using (Html.BeginForm(new { Controller = "Product", Action = "Add" }))
{
    <div id="toolbar-box">
        <div class="t">
            <div class="t">
                <div class="t">
                </div>
            </div>
        </div>
        <div class="m">
            <div class="toolbar-list" id="toolbar">
                <ul>
                    @*<li id="toolbar-apply" class="button"><a class="toolbar" href="#"><span class="icon-32-apply"
                        title="Lưu"></span>Lưu </a></li>*@
                    <li id="toolbar-apply" class="button">
                        <input value="Lưu" type="submit" /></li>
                    <li id="toolbar-save" class="button"><a class="toolbar" href="#"><span class="icon-32-save"
                        title="Lưu & đóng"></span>Lưu & đóng </a></li>
                    <li id="toolbar-save-new" class="button"><a class="toolbar" href="#"><span class="icon-32-save-new"
                        title="Lưu & thêm"></span>Lưu & thêm </a></li>
                    <li class="divider"></li>
                    <li id="toolbar-cancel" class="button"><a onclick="vsw_exec_cmd(cancel)" class="toolbar"
                        href="#"><span class="icon-32-cancel" title="Đóng"></span>Đóng </a></li>
                </ul>
            </div>
            <div class="pagetitle icon-48-generic">
                <h2>
                    SẢN PHẨM : @(Model.Product != null && Model.Product.Id > 0 ? "Chỉnh sửa" : "Thêm mới")</h2>
            </div>
            <div class="clr">
            </div>
        </div>
        <div class="b">
            <div class="b">
                <div class="b">
                </div>
            </div>
        </div>
    </div>
    <div class="clr">
    </div>
@*<%= ShowMessage()%>*@
    <div id="element-box">
        <div class="t">
            <div class="t">
                <div class="t">
                </div>
            </div>
        </div>
        <div class="m">
            <div class="width-70 fltlft">
                <fieldset class="adminform">
                    <legend>THÔNG TIN CHUNG</legend>
                    <table class="admintable">
                        <tr>
                            <td class="key">
                                <label>
                                    TÊN SẢN PHẨM :</label>
                            </td>
                            <td>
                                @Html.TextBox("txtName", Model.Product.Name, new { @class = "text-input", maxlength = "255" })
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                <label>
                                    MÔ TẢ NGẮN GỌN :</label>
                            </td>
                            <td>
                                @Html.TextBox("txtShortDescription", Model.Product.ShortDescription, new { @class = "text-input", maxlength = "255" })
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" style="text-align: center" class="key">
                                NỘI DUNG
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" class="content">
                                @Html.TextArea("txtFullDescription", Model.Product.FullDescription, new { @class = "ckeditor", id = "Content" })
                                @*<textarea rows="10" class="ckeditor" style="width: 100%; height: 500px" name="txtFullDescription"
                                    id="Content" ></textarea>*@
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>
            <div class="width-30 fltrt">
                <div id="content-sliders-" class="pane-sliders">
                    <div class="panel">
                        <h3 class="pane-toggler title" id="publishing-details">
                            <a href="javascript:void(0);"><span>THUỘC TÍNH</span></a></h3>
                        <div class="pane-slider content">
                            <table class="admintable">
                                <tr>
                                    <td align="center" style="text-align: center" class="key">
                                        Danh mục sản phẩm
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Html.DropDownList("ddlCategoryId", new SelectList(Model.ParentCategories, "Id", "Name"), "--Chọn danh mục sản phẩm--", new { @class = "text-Input" })
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="text-align: center" class="key">
                                        Hình ảnh
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Vui lòng tạo sản phẩm trước @* @if (!string.IsNullOrEmpty(Model.New.Image))
                                        {
                                            @Project.MVC.Util.Utils.GetMedia(Model.New.Image, 100, 80, string.Empty, true, "id='img_view'")}
                                        else
                                        { 
                                            <img id="img_view" width="100" height="80" />
                                        }
                                        <br />
                                        @Html.TextBox("txtImageUrl")
                                        <input type="button" value="Select ..." id="btnSelectImg" name="btnSelectImg" />
                                        <input class="text_input" type="text" name="File" id="File" style="width: 65%" />
                                        <input class="text_input" style="width: 75px;" type="button" onclick="ShowFileForm('File');return false;"
                                            value="Chọn ảnh" />*@
                                    </td>
                                </tr>
                                @*<tr>
                                    <td align="center" style="text-align: center" class="key">
                                        Hiển thị trang chủ
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        
                                        @Html.CheckBox("cbHome",Model.New.IsHome)
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="text-align: center" class="key">
                                        Nổi bật
                                    </td>
                                </tr>
                                <tr>
                                    <td>                                        
                                        @Html.CheckBox("cbHot", Model.New.IsHot)
                                    </td>
                                </tr>
                                 <tr>
                                <td align="center" style="text-align:center" class="key">
                                   Còn hàng
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input name="Available" <%= entity.Available ? "checked" : "" %> type="radio" value='1' /> Có
                                    <input name="Available" <%= !entity.Available ? "checked" : "" %> type="radio" value='0' /> Không
                                </td>
                            </tr>*@ @*<%if(CPViewPage.UserPermissions.Approve) {%>*@ @*   <tr>
                                <td align="center" style="text-align: center" class="key">
                                    Duyệt
                                </td>
                            </tr>
                            <tr>
                                <td>
                                   <input name="Activity" <%= entity.Activity ? "checked" : "" %> type="radio" value='1' /> Có
                                    <input name="Activity" <%= !entity.Activity ? "checked" : "" %> type="radio" value='0' /> Không
                                </td>
                            </tr>
                             <%} %>*@
                            </table>
                        </div>
                    </div>
                    @* <div class="panel">
                    <h3 class="pane-toggler title" id="basic-options">
                        <a href="javascript:void(0);"><span>THÔNG TIN THÊM</span></a></h3>
                    <div class="pane-slider content">
                        <textarea class="text_input" style="height:100px;" name="Custom" id="custom"><%=entity.Custom%></textarea>
                        <textarea class="text_input" style="height:50px;" name="set_custom" id="set_custom"></textarea>
                        <table width="99%">
                            <tr>
                                <td width="100%">
                                    <input name="rSetCustom" onclick="GetCustom(this.value)" type="radio" checked value="Keywords" />Từ khóa
                                    <br />
                                    <input name="rSetCustom" onclick="GetCustom(this.value)" type="radio" value="Description" />Diễn giải
                                </td>
                                <td>
                                    <input type="button" class="text_input" style="width:100px;" onclick="SetCustom(); return false;" value="Cập nhật" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>*@
                </div>
            </div>
            <div class="clr">
            </div>
        </div>
        <div class="b">
            <div class="b">
                <div class="b">
                </div>
            </div>
        </div>
    </div>
   
    <script src="@Url.Content("~/content/ckeditor/ckeditor.js")" type="text/javascript"></script>
    @*<script type="text/javascript">

        CKEDITOR.replace('txtDescription');
    
    </script>*@
    <!--Config CKFinder-->
    <script src="@Url.Content("~/content/ckfinder/ckfinder.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnSelectImg").click(function () {
                var finder = new CKFinder();
                finder.selectActionFunction = function (fileUrl) {
                    $('#txtImageUrl').val(fileUrl);
                    $('#img_view').attr("src", fileUrl);
                };
                finder.popup();
            });
        });

        function SetFileField(fileUrl) {
            alert(fileUrl);
            $('#ImageUrlssss').val(fileUrl);
        }
    
    </script>    



    <script type="text/javascript">
        CKFinder.setupCKEditor(null, '/Content/ckfinder/');

        //    function refreshPage(arg) {
        //        arg = '~' + arg;
        //        document.getElementById(name_control).value = arg;
        //        if (document.getElementById("img_view"))
        //            document.getElementById("img_view").src = arg.replace('~/', '/{ApplicationPath}');
        //    }

        //GetCustom('Keywords');

    </script>
 
}